package com.mofofa.maozy.launch

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.mofofa.maozy.R
import com.mofofa.maozy.components.form.*
import com.mofofa.maozy.data.DataPermission

class PermissionAdapter(private val dataList: List<DataPermission>) :
    RecyclerView.Adapter<PermissionAdapter.ViewHolder>() {

    inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        var imageMaozyAdpterMaozyPermission: ImageView =
            view.findViewById(R.id.imageAdpterPermission)
        var textMaozyAdpterMaozyPermissionMaozyTitle: TextView =
            view.findViewById(R.id.textAdpterPermissionTitle)
        var textMaozyAdpterMaozyPermissionMaozyDetail: TextView =
            view.findViewById(R.id.textAdpterPermissionDetail)
    }

    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int,
    ): ViewHolder {
        val view = LayoutInflater.from(parent.context)
            .inflate(R.layout.view_maozy_adpter_permission, parent, false)
        return ViewHolder(view)
    }

    @SuppressLint("SetTextI18n")
    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val data: DataPermission = dataList[position]
        holder.imageMaozyAdpterMaozyPermission.setImageResource(data.imgRes)
        holder.textMaozyAdpterMaozyPermissionMaozyTitle.text = (data.title)
        holder.textMaozyAdpterMaozyPermissionMaozyDetail.text = (data.detail)
    }

    override fun getItemCount(): Int {
        return dataList.size
    }
}